
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter/src/widgets/framework.dart';
import 'package:reabampos/src/reabam/operation/rb_api.dart';
import 'package:reabampos/src/reabam/operation/rb_config.dart';
import 'package:reabampos/src/reabam/ui_self_service/pagestate_ss_login.dart';
import 'package:reabampos/src/reabam/ui_self_service/shoppingcart/pagestate_ss_manual_input_gooditem_barcode_search.dart';
import 'package:reabampos/src/reabam/ui_self_service/shoppingcart/pagestate_ss_pay_result.dart';
import 'package:reabampos/src/reabam/utils/rb_color.dart';
import 'package:reabampos/src/reabam/utils/rb_widget_ss.dart';
import 'package:xsdk_flutter/xsdk/utils/x_utils_string.dart';
import 'package:xsdk_flutter/xsdk/xsdk_flutter_package.dart';

/*
支付
 */
class PageStateSelfServicePay extends XPageState{

  bool isPayWaiting=false;

  PageStateSelfServicePay();

  @override
  void onCreate() {
    super.onCreate();
    RBConfigs.isPageScanType=2;
  }

  @override
  void onStart() {

    setXTopBarWidget(
        height: null,
        child: RBWidgets_SelfService.getTitleBarWidget(
          this,
          title: '付款',
        )
    );

  }

  @override
  Widget getBodyWidget(BuildContext context) {
    return XWidgetUtils.getLayoutContainer(
        alignment: Alignment.topCenter,
        padding: XWidgetUtils.getEdgeInsets(0, 100, 0, 0),
        child: XWidgetUtils.getLayoutColumn(
            crossAxisAlignment :CrossAxisAlignment.center,
            children: [
              XWidgetUtils.getWidgetText(
                  '¥0.00',
                  style: XStyleUtils.getTextStyle(
                      fontSize: 60,
                      color: XColorUtils.color333333,
                      fontWeight: FontWeight.bold
                  )
              ),
              XWidgetUtils.getLayoutContainer(
                  alignment: Alignment.center,
                  child: XWidgetUtils.getLayoutRow(
                      mainAxisSize:MainAxisSize.min,
                      mainAxisAlignment:MainAxisAlignment.center,
                      children: [
                        XWidgetUtils.getWidgetText(
                            '0',
                            style: XStyleUtils.getTextStyle(
                              fontSize: 50,
                              color: const Color(0xFFFF0020),
                            )
                        ),
                        XWidgetUtils.getWidgetText(
                            '件商品',
                            style: XStyleUtils.getTextStyle(
                              fontSize: 40,
                              color: XColorUtils.color999999,
                            )
                        ),
                      ]
                  )
              ),
              XWidgetUtils.getWidgetText(
                '请在下方扫码区扫描付款码',
                style: XStyleUtils.getTextStyle(
                  fontSize: 40,
                  color: XColorUtils.color333333,
                ),
                padding: XWidgetUtils.getEdgeInsets(0, 188, 0, 0),
              ),
              XWidgetUtils.getLayoutContainer(
                margin: XWidgetUtils.getEdgeInsets(50, 21, 50, 0),
                alignment: Alignment.center,
                height: 693,
                child: XWidgetUtils.getLayoutStack(
                    alignment:AlignmentDirectional.center,
                    children: [
                      XImageUtils.getImageWidgetWithAsset(
                        'ss_pay_bg_logo.png',
                        width: 501,
                        height: 560,
                      ),
                      isPayWaiting?XWidgetUtils.getXLayoutRoundedRect(
                        radius_topLeft: 30,
                          radius_topRight: 30,
                          radius_bottomRight: 30,
                          radius_bottomLeft: 30,
                          backgroundColor: const Color(0x66000000),
                          alignment: Alignment.center,
                          height: 693,
                          width: double.infinity,
                          child: XWidgetUtils.getWidgetText(
                              '（8）等待支付结果…',
                            style: XStyleUtils.getTextStyle(
                              fontSize: 50,
                              color: Colors.white,
                              fontWeight: FontWeight.bold
                            )
                          )
                      ):XWidgetUtils.getLayoutContainer()
                    ]
                )
              ),

              XWidgetUtils.getWidgetText(
                '支持支付方式',
                style: XStyleUtils.getTextStyle(
                  fontSize: 40,
                  color: XColorUtils.color333333,
                ),
                padding: XWidgetUtils.getEdgeInsets(0, 76, 0, 0),
              ),
              XWidgetUtils.getLayoutContainer(
                  margin: XWidgetUtils.getEdgeInsets(165, 40, 165, 0),
                  child: XWidgetUtils.getLayoutRow(
                      children: [
                        XWidgetUtils.getLayoutExpanded(
                            XWidgetUtils.getLayoutContainer(
                                backgroundColor: Colors.white,
                                alignment: Alignment.center,
                                child: XWidgetUtils.getLayoutRow(
                                    mainAxisAlignment:MainAxisAlignment.center,
                                    children: [
                                      XImageUtils.getImageWidgetWithAsset(
                                        'ss_pay_weixin.png',
                                        width: 121,
                                        height: 120,
                                      ),
                                      XWidgetUtils.getWidgetText(
                                          '微信支付',
                                          style: XStyleUtils.getTextStyle(
                                            fontSize: 40,
                                            color: XColorUtils.color333333,
                                          ),
                                          padding: XWidgetUtils.getEdgeInsets(21, 0, 0, 0)
                                      )
                                    ]
                                )
                            )
                        ),
                        XWidgetUtils.getLayoutExpanded(
                            XWidgetUtils.getLayoutContainer(
                                backgroundColor: Colors.white,
                                alignment: Alignment.center,
                                child: XWidgetUtils.getLayoutRow(
                                    mainAxisAlignment:MainAxisAlignment.center,
                                    children: [
                                      XImageUtils.getImageWidgetWithAsset(
                                        'ss_pay_zhifubao.png',
                                        width: 121,
                                        height: 120,
                                      ),
                                      XWidgetUtils.getWidgetText(
                                          '支付宝支付',
                                          style: XStyleUtils.getTextStyle(
                                            fontSize: 40,
                                            color: XColorUtils.color333333,
                                          ),
                                          padding: XWidgetUtils.getEdgeInsets(21, 0, 0, 0)
                                      )
                                    ]
                                )
                            )
                        ),
                      ]
                  )
              ),
              XWidgetUtils.getLayoutContainer(
                  margin: XWidgetUtils.getEdgeInsets(0, 108, 0, 0),
                  alignment: Alignment.center,
                  child: XWidgetUtils.getLayoutRow(
                      mainAxisAlignment:MainAxisAlignment.center,
                      children: [
                        XWidgetUtils.getWidgetText(
                            '请在 ',
                            style: XStyleUtils.getTextStyle(
                              fontSize: 40,
                              color: XColorUtils.color333333,
                            ),
                        ),
                        XWidgetUtils.getWidgetText(
                            '120s',
                            style: XStyleUtils.getTextStyle(
                              fontSize: 40,
                              color: const Color(0xFFFF0020),
                            ),
                        ),
                        XWidgetUtils.getWidgetText(
                            ' 内完成支付',
                            style: XStyleUtils.getTextStyle(
                              fontSize: 40,
                              color: XColorUtils.color333333,
                            ),
                        ),
                      ]
                  )
              ),

            ]
        )
    );
  }



  @override
  Future<void> updateData({int pageIndex = 1}) async {

    //startPage(PageStateSelfServicePayResult());
  }


  @override
  Color getXPageBackgroundColor() {
    return Colors.white;
  }


}